
class SqlFetchAll:
    ''' small wrapper class that enables you to use fetchone() as if it were fetchall

        when retrieving large datasets using fetchall() is often not acceptable
        http://mail.python.org/pipermail/db-sig/1999-December/001102.html
    '''
    def __init__(self, cursor):
        self.__cursor = cursor

    def __getitem__(self, index):
        # The indices had better be in order, because we're not
        # wasting time checking them.
        result = self.__cursor.fetchone()
        if result is not None:
            return result
        else:
            raise IndexError
